package samsung.entities;

import samsung.other.CountryArea;
import samsung.other.Position;

/**
 * Class need to construct <code>Country</code> object.
 *
 * @author Vitaliy Muzalevskiy
 */
public class CountryBuilder {  
    
    private CityBuilder builder = new CityBuilder();
    
    /**
     * Method realized country construction with defined parameters.
     *
     * @param countryArea - <code>CountryArea</code> value that country takes
     *      in current area.
     * @param name - name of the country.
     * @return - constructed <code>Country</code> object.
     */
    public Country buildCountry(CountryArea countryArea, String name){
        Country result = new Country(countryArea, name);
        City city;
        for(int y = countryArea.getDownLeftPoint().getY(); 
                y <= countryArea.getUpRightPoint().getY(); y++){
            for(int x = countryArea.getDownLeftPoint().getX();
                    x <= countryArea.getUpRightPoint().getX(); x++){
                city = builder.buildCity(new Position(x, y), name);
                result.addCity(city);
            }
        }
        return result;
    }
    
}
